<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="d1">这是div</div>
<input type="text" id="myinput">
<input type="button" value="按钮" onclick="myfn()">
<hr>
<input type="text" id="num_input">
<input type="button" value="计算" onclick="jisuan()">

<script>

    function jisuan() {
    let i = document.getElementById("num_input");
    let d = document.getElementById("d1");

    // d.innerText = i.value*i.value;
    // i.value得到的是字符串，进行- * / 时会自动转成数值 +则是字符串拼接
    // value*1和parseInt(value)都是将字符串转成数值的方式

    // d.innerText=i.value*1+i.value*1;
    d.innerText=parseInt(i.value)+parseInt(i.value);
    }


    function myfn() {
     let d = document.getElementById("d1");
     let i = document.getElementById("myinput");
     d.innerText = i.value;
    }


</script>
</body>
</html>